package 笔试.HF;

/**
 * @author:谢君臣
 * @Date:2021/7/24-19:29
 * @version:1.0
 * @function:
 */
public class HF_DD2 {
    public static void main(String[] args) {
        System.out.println(Solution.add(8,9));
    }





}
class Solution{
    // 加法
    public static int add(int num1 ,int num2){
        num1 +=num2;
        return out(num1);
    }
    // 减法
    public static int reduce(int num1 ,int num2){
        num1 -=num2;
        return out(num1);
    }
    //先将十进制转换成三进制;
    public static int out(int num) {
        StringBuilder res = new StringBuilder();
        if (num >= 0) {
            while (num>0){
                res.append(num % 3);
                num = num / 3;
            }
        } else
            System.out.println("The number is wrong!");
        return Integer.parseInt(res.reverse().toString());
    }
}

